package com.ruoyi.ade.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ade.domain.AdeKnowledgeRecord;
import com.ruoyi.ade.service.IAdeKnowledgeRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ADE KB RecordsController
 * 
 * @author wxh
 * @date 2025-07-07
 */
@RestController
@RequestMapping("/ade/adekbrecord")
public class AdeKnowledgeRecordController extends BaseController
{
    @Autowired
    private IAdeKnowledgeRecordService adeKnowledgeRecordService;

    /**
     * 查询ADE KB Records列表
     */
    @PreAuthorize("@ss.hasPermi('ade:adekbrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdeKnowledgeRecord adeKnowledgeRecord)
    {
        startPage();
        List<AdeKnowledgeRecord> list = adeKnowledgeRecordService.selectAdeKnowledgeRecordList(adeKnowledgeRecord);
        return getDataTable(list);
    }

    /**
     * 导出ADE KB Records列表
     */
    @PreAuthorize("@ss.hasPermi('ade:adekbrecord:export')")
    @Log(title = "ADE KB Records", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdeKnowledgeRecord adeKnowledgeRecord)
    {
        List<AdeKnowledgeRecord> list = adeKnowledgeRecordService.selectAdeKnowledgeRecordList(adeKnowledgeRecord);
        ExcelUtil<AdeKnowledgeRecord> util = new ExcelUtil<AdeKnowledgeRecord>(AdeKnowledgeRecord.class);
        util.exportExcel(response, list, "ADE KB Records数据");
    }

    /**
     * 获取ADE KB Records详细信息
     */
    @PreAuthorize("@ss.hasPermi('ade:adekbrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(adeKnowledgeRecordService.selectAdeKnowledgeRecordById(id));
    }

    /**
     * 新增ADE KB Records
     */
    @PreAuthorize("@ss.hasPermi('ade:adekbrecord:add')")
    @Log(title = "ADE KB Records", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdeKnowledgeRecord adeKnowledgeRecord)
    {
        return toAjax(adeKnowledgeRecordService.insertAdeKnowledgeRecord(adeKnowledgeRecord));
    }

    /**
     * 修改ADE KB Records
     */
    @PreAuthorize("@ss.hasPermi('ade:adekbrecord:edit')")
    @Log(title = "ADE KB Records", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdeKnowledgeRecord adeKnowledgeRecord)
    {
        return toAjax(adeKnowledgeRecordService.updateAdeKnowledgeRecord(adeKnowledgeRecord));
    }

    /**
     * 删除ADE KB Records
     */
    @PreAuthorize("@ss.hasPermi('ade:adekbrecord:remove')")
    @Log(title = "ADE KB Records", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adeKnowledgeRecordService.deleteAdeKnowledgeRecordByIds(ids));
    }
}
